<template>
  <view>
    <l-form-cell v-model="form.idCardNo" label="身份证号" :must="type == 2 && !disabled" :disabled="disabled" placeholder="请输入司机身份证号" />
    <l-form-cell label="身份证有效截止日期" label-width="290rpx" has-slot :arrow="!disabled" :unlined="!disabled" :must="type == 2 && !disabled" @click="changeDate('idCardValidDateEnd')">
      <view class="form-item flex-row form-item align-center justify-end">
        <text class="text-30" :class="['color-t' + (form.idCardValidDateEnd ? 1 : 3)]">{{ form.idCardValidDateEnd || '请选择日期' }}</text>
      </view>
    </l-form-cell>
  </view>
</template>

<script>
export default {
  name: 'IdCardInfoModel',
  props: {
    type: {
      type: [String, Number],
      default: 0
    },
    data: {
      type: Object,
      default: () => {}
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {
        idCardNo: '',
        idCardValidDateEnd: ''
      }
    }
  },
  watch: {
    data: {
      handler(e) {
        Object.keys(this.form).forEach(item => {
          this.form[item] = e[item]
        })
      },
      deep: true
    },
    form: {
      handler() {
        this.$emit('update', this.form)
      },
      deep: true
    }
  },

  methods: {
    // 修改日期
    changeDate(attr) {
      this.$emit('changeDate', attr)
    }
  }
}
</script>

<style scoped>

</style>
